package event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.web.context.support.RequestHandledEvent;

public class EventListener implements ApplicationListener {

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        if (ContextRefreshedEvent.class.isInstance(event)) {
            System.out.println("ContextRefreshedEvent");
        } else if (ContextStartedEvent.class.isInstance(event)) {
            System.out.println("ContextStartedEvent");
        } else if (ContextStoppedEvent.class.isInstance(event)) {
            System.out.println("ContextStoppedEvent");
        } else if (ContextClosedEvent.class.isInstance(event)) {
            System.out.println("ContextClosedEvent");
        } else if (RequestHandledEvent.class.isInstance(event)) {
            System.out.println("RequestHandledEvent");
        }
    }
}
